<!DOCTYPE html>
<html 
	lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		
<link rel="stylesheet" href="/css/layout.css">

		
		<title> C语言指针 -  森屿安年</title>
		<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" />
		<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
		<!-- lazyload -->
		<script src="https://unpkg.com/lazysizes@5.1.0/lazysizes.min.js"></script>
		<!-- smooth-scrolling -->
		<script src="https://unpkg.com/smooth-scrolling.js@1.0.0"></script>
		<!-- highlight -->
		<link rel="stylesheet" href="//unpkg.com/@highlightjs/cdn-assets@11.6.0/styles/atom-one-dark.min.css" />
		<script src="//unpkg.com/@highlightjs/cdn-assets@11.6.0/highlight.min.js"></script>
		<!-- 预置 kiraicon -->
		
<link rel="stylesheet" href="/lib/iconfont/iconfont.css">

		
		<link
			rel="shortcut icon"
			href="https://picshack.net/ib/HqilSRY4zh.png"
			type="image/png"
		/>
		
<link rel="stylesheet" href="/deps/css/APlayer.min.css">

		
			
				
<link rel="stylesheet" href="/style.css">

			
				
<link rel="stylesheet" href="/custom.css">

			
		
		
<script src="/deps/js/APlayer.min.js"></script>
<script src="/deps/js/Meting.min.js"></script>

	<meta name="generator" content="Hexo 7.0.0"></head>

	<body>
		<div
			class="kira-background"
			style="background-image: url('https://picshack.net/ib/i7qQmtNNm0.jpg')"
		></div>
		<div class="kira-header">
    <a
        class="kira-drawer-button mdui-ripple"
        title="导航栏"
        onclick="document.querySelector('.kira-sidebar-modal').classList.add('show');document.querySelector('.kira-sidebar#sidebar').classList.add('show');"
    >
        <i class="kirafont icon-menu"></i>
    </a>
    <a href="/" title="森屿安年">
        <img
			src="https://picshack.net/ib/HqilSRY4zh.png"
			alt="森屿安年"
		/>
    </a>
</div>
		<div class="kira-body">
			<div class="kira-sidebar" id="sidebar">
	<div class="kira-avatar mdui-ripple">
		<a target="_blank" rel="noopener" href="https://picshack.net/ib/HqilSRY4zh.png" title="森屿安年">
			<img
				src="https://picshack.net/ib/HqilSRY4zh.png"
				alt="森屿安年"
			/>
		</a>
	</div>
	<div class="kira-count">
		<div><span>文章</span>4</div>
		<div><span>标签</span>0</div>
		<div><span>分类</span>0</div>
	</div>
	<div class="kira-list">
		
		<a
			class="kira-list-item mdui-ripple false"
			href="/"
			title="回到首页"
		>
			<i
				class="kirafont
					
						icon-home
					"
			></i>
			<div class="kira-list-item-content">
				回到首页
			</div>
		</a>
		
		<a
			class="kira-list-item mdui-ripple false"
			href="/archive.html"
			title="文章归档"
		>
			<i
				class="kirafont
					
						icon-container
					"
			></i>
			<div class="kira-list-item-content">
				文章归档
			</div>
		</a>
		
		<a
			class="kira-list-item mdui-ripple false"
			href="/about.html"
			title="关于本人"
		>
			<i
				class="kirafont
					
						icon-user
					"
			></i>
			<div class="kira-list-item-content">
				关于本人
			</div>
		</a>
		
		<a
			class="kira-list-item mdui-ripple false"
			href="/friends.html"
			title="我的朋友"
		>
			<i
				class="kirafont
					
						icon-team
					"
			></i>
			<div class="kira-list-item-content">
				我的朋友
			</div>
		</a>
		
	</div>
	<aside id="kira-sidebar">
		
			<div class="kira-widget-wrap">
	<div class="kira-widget kira-social">
		
			<a
				class="mdui-ripple"
				href="https://qm.qq.com/q/8Sew059c0U"
				target="_blank"
				mdui-tooltip="{content: 'QQ'}"
				style="color: rgb(49, 174, 255); background-color: rgba(49, 174, 255, .1);"
			>
				<i
					class="kirafont
					
						icon-QQ
					"
				></i>
			</a>
		
			<a
				class="mdui-ripple"
				href="https://space.bilibili.com/15270310?spm_id_from=333.1007.0.0"
				target="_blank"
				mdui-tooltip="{content: '哔哩哔哩'}"
				style="color: rgb(231, 106, 141); background-color: rgba(231, 106, 141, .15);"
			>
				<i
					class="kirafont
					
						icon-bilibili
					"
				></i>
			</a>
		
			<a
				class="mdui-ripple"
				href="https://github.com/hyperexceed"
				target="_blank"
				mdui-tooltip="{content: 'GitHub'}"
				style="color: rgb(25, 23, 23); background-color: rgba(25, 23, 23, .15);"
			>
				<i
					class="kirafont
					
						icon-github
					"
				></i>
			</a>
		
			<a
				class="mdui-ripple"
				href="https://gitee.com/senyu-annian"
				target="_blank"
				mdui-tooltip="{content: 'Gitee'}"
				style="color: rgb(165, 15, 15); background-color: rgba(165, 15, 15, .15);"
			>
				<i
					class="kirafont
					
						icon-gitee
					"
				></i>
			</a>
		
	</div>
</div>

		
			
		
			

		
	</aside>
	<div class="kira-copyright">
		&copy; 2024
		<a href="/">森屿安年</a>
		Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> &
		<a href="https://github.com/ch1ny/kira-hexo/" target="_blank">Kira-Hexo</a>
		<br />
		
			<a
				href="https://beian.miit.gov.cn/"
				target="_blank"
			>
				赣ICP备******号
			</a>
		
		
	</div>
</div>
<div
	class="kira-sidebar-modal"
	id="sidebar-modal"
	onclick="(function(self) {
		self.classList.remove('show');
		document.querySelector('.kira-sidebar.show#sidebar').classList.remove('show');
	})(this)"
></div>
			<div class="kira-content">
				<div id="kira-top-header"></div>
				<div class="kira-main-content">
					
<link rel="stylesheet" href="/css/kira-image.css">


<script src="/js/kira-image.js"></script>

<div class="kira-image">
    <div class="kira-image-modal">
        <div class="kira-image-header">
            <div class="kira-image-counter"></div>
            <div class="kira-image-title"></div>
            <div class="kira-image-operation">
                <div class="kira-image-operation-button" id="kira-image-operation-button-zoom">
                    <i class="kirafont icon-zoom-in"></i>
                </div>
                <div class="kira-image-operation-button" id="kira-image-operation-button-close">
                    <i class="kirafont icon-close"></i>
                </div>
            </div>
        </div>
        <div class="kira-image-container">
            <div class="kira-image-prev-button-panel">
                <div class="kira-image-exchange-button">
                    <i class="kirafont icon-left"></i>
                </div>
            </div>
            <div class="kira-image-list">
                <div class="kira-image-prev">
                    <img />
                </div>
                <div class="kira-image-now">
                    <img />
                </div>
                <div class="kira-image-next">
                    <img />
                </div>
            </div>
            <div class="kira-image-next-button-panel">
                <div class="kira-image-exchange-button">
                    <i class="kirafont icon-right"></i>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="kira-post">
	<article>
		
		<div
			class="kira-post-cover"
			style="padding-bottom: '56.25%'"
		>
			<img
				data-src="https://picshack.net/ib/i7qQmtNNm0.jpg"
				data-sizes="auto"
				alt="C语言指针"
				class="lazyload kira-post-cover-image disabled-kira-image"
			/>
			<h1>C语言指针</h1>
		</div>
		
		<div class="kira-post-meta kira-rainbow" style="margin:10px 0!important;">
			<a><i class="kirafont icon-calendar-fill"></i>2024年01月08日</a>
			<a><i class="kirafont icon-edit-fill"></i>268 字</a>
			<a><i class="kirafont icon-time-circle-fill"></i>大概 1 分钟</a>
		</div>
		<h3><span id="一指针的概念">一.指针的概念</span></h3><p>计算机中的内存，会被划分为一个个内存单元，而每个内存单元的大小都是<strong>1bit</strong>并且都有一个自己的地址，这就类似于现实中的一个城市，一个城市内有很多的房屋，每个房屋都有自己的地址，在C语言中，<strong>这个地址就是指针</strong>.</p>
<p><img src="https://picshack.net/ib/MigfdDAj6P.png"></p>
<h3><span id="二指针变量">二.指针变量</span></h3><p>指针变量是一个变量，用来<strong>存放其它变量的地址</strong>.</p>
<p>具体示例：</p>
<p><img src="https://picshack.net/ib/OQvOHvXBdt.png"></p>
<p>此处指针变量p的数据类型为<strong>int*类型</strong>，存放了变量a的地址.</p>
<p>此时指针变量p指向了变量a的内存空间.</p>
<p>具体关系为:</p>
<p><img src="https://picshack.net/ib/N3n8BR2UuA.png"></p>
<p>对指针变量p进行<strong>解引用</strong>，就可以访问到变量a的内存空间中存放的数据并进行修改.</p>
<p><img src="https://picshack.net/ib/YUr847xggc.png"></p>
<p>指针变量的大小在不同位数的计算机下是不同的，具体为：</p>
<p>1.<strong>32位机器</strong>下，指针变量的大小为<strong>4个字节</strong></p>
<p>2.<strong>64位机器</strong>下，指针变量的大小为8个字节</p>
<p><img src="https://picshack.net/ib/TTYNbfM92N.png"></p>
<p><img src="https://picshack.net/ib/Nihf1nIZoe.png"></p>
<h3><span id></span></h3>
	</article>

	 
    <div class="kira-post-copyright">
        <strong>本文作者：</strong>森屿安年<br>
        <strong>本文链接：</strong><a href="https://senyu-annian.gitee.io/2024/01/08/%E6%8C%87%E9%92%88/" title="https:&#x2F;&#x2F;senyu-annian.gitee.io&#x2F;2024&#x2F;01&#x2F;08&#x2F;指针&#x2F;" target="_blank" rel="noopener">https:&#x2F;&#x2F;senyu-annian.gitee.io&#x2F;2024&#x2F;01&#x2F;08&#x2F;指针&#x2F;</a><br>
        
            <strong>版权声明：</strong>本文采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/deed.zh" target="_blank">CC BY-NC-SA 3.0 CN</a> 协议进行许可
        
    </div>

  
	<div class="kira-post-nav">
		<nav class="post-nav">
			
		</nav>
	</div>
	
	<div class="kira-post-meta kira-rainbow">
		
		
	</div>
	
		
<script src="/js/kira-code-copy.js"></script>

	
	
	<div class="kira-post-footer">
		

		
	<div class="giscus"></div>
  
    <script src="https://giscus.app/client.js"
      data-repo="ch1ny/ch1ny.github.io"
      data-repo-id="R_kgDOHGgizw"
      data-category="General"
      data-category-id="DIC_kwDOHGgiz84CU88t"
      data-mapping="pathname"
      data-strict="0"
      data-reactions-enabled="1"
      data-emit-metadata="0"
      data-input-position="top"
      data-theme="light"
      data-lang="en"
      data-loading="lazy"
      crossorigin="anonymous"
      async  
    ></script>
  

	</div>
	
</div>

				</div>
			</div>
			<div class="kira-right-column">
	<a onclick="document.querySelector('#kira-top-header').scrollIntoView({behavior: 'smooth'});" class="kira-backtotop" aria-label="回到顶部" title="回到顶部">
		<button class="mdui-fab mdui-ripple">
			<i class="kirafont icon-caret-up"></i>
		</button>
	</a>
</div>

		</div>
	</body>
</html>
